//
//  BindThirdPartAuthViewController.m
//  quxiangtao
//
//  Created by xbmios on 2018/11/5.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "BindThirdPartAuthViewController.h"
#import "JTNavigationController.h"
@interface BindThirdPartAuthViewController ()

@property (strong, nonatomic) UIScrollView *contentScrollView;

@property (strong, nonatomic) UIImageView *titileIV;

@property (strong, nonatomic) UIImageView *leftIV;
@property (strong, nonatomic) UIImageView *rightIV;
@property (strong, nonatomic) UILabel *desL;

// 手机号
@property (strong, nonatomic) UIImageView *phoneIV;
@property (strong, nonatomic) UILabel *phoneL;
@property (strong, nonatomic) UILabel *phoneZoneL;
@property (strong, nonatomic) UITextField *phoneTextField;
@property (strong, nonatomic) UIView *shortLineIV;
@property (strong, nonatomic) UIView *middleLineIV;

// 验证码
@property (strong, nonatomic) UIImageView *codeIV;
@property (strong, nonatomic) UILabel *codeL;
@property (strong, nonatomic) UITextField *codeTextField;
@property (strong, nonatomic) UIButton *getCodeBtn;
@property (strong, nonatomic) UIView *codeLineIV;

// 密码
@property (strong, nonatomic) UIImageView *passwordIV;
@property (strong, nonatomic) UILabel *passwordL;
@property (strong, nonatomic) UITextField *passwordTextField;
@property (strong, nonatomic) UIView *passwordLineIV;

// 确认密码
@property (strong, nonatomic) UIImageView *confirmPasswordIV;
@property (strong, nonatomic) UILabel *confirmPasswordL;
@property (strong, nonatomic) UITextField *confirmPasswordTextField;
@property (strong, nonatomic) UIView *confirmPasswordLineIV;

@property (strong, nonatomic) UILabel *registerProtocolL;
@property (strong, nonatomic) UILabel *protocolL;

@property (strong, nonatomic) UIButton *registerBtn;

@property (strong, nonatomic) UILabel *registerL;

@end

@implementation BindThirdPartAuthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = WhiteColor;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    UIButton *btn = [[UIButton alloc] init];
    //        btn.frame = CGRectMake(0, 0, jisuan(18), jisuan(32));
    btn.frame = CGRectMake(0, 0, jisuan(50), jisuan(50));
    [btn setImage:[UIImage imageNamed:@"nav_go_back"] forState:UIControlStateNormal];
    //设置点击图像
    [btn setBackgroundImage:nil forState:UIControlStateHighlighted];
    [btn addTarget:self action:@selector(backClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *btnItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    self.navigationItem.leftBarButtonItem = btnItem;
    
    
    [self createView];

}

- (void)backClick:(UIButton *)btn {
    
    [[ALBBSDK sharedInstance] logout];
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

#pragma mark -协议点击
- (void)protocolClick:(UIGestureRecognizer *)recognizer {
    
    NSLog(@"协议点击");
    
    WebViewController *vc = [[WebViewController alloc] init];
    vc.title = @"用户协议";
    vc.url = @"http://www.quxiangtao.com/H5/invitatRegist/agreement.html";
    [self.navigationController pushViewController:vc animated:YES];
    
}

#pragma mark -获取验证码
- (void)getCodeBtnClick:(UIButton *)btn {
    
    NSLog(@"获取验证码");
    
    [[CommonAction sharedInstance] getCodeWithPhone:self.phoneTextField.text type:@"empower" andSender:btn phoneCodeBlock:^(NSString *codeStr) {
        
        NSLog(@"验证码L:%@", codeStr);
        //        self.codeNumStr = [NSString stringWithFormat:@"%@", codeStr];
        
    }];
    
}

- (void)registerLClick:(UIGestureRecognizer *)recognizer {
    
    [self loadData];
    
}

#pragma mark -绑定手机号
- (void)registerBtnClick:(UIButton *)btn {

    [self loadData];
    
}

- (void)loadData {
    
    NSString *user_mobile = [RSA encryptString:self.phoneTextField.text publicKey:PublicKey];
    NSString *code = [RSA encryptString:self.codeTextField.text publicKey:PublicKey];
    NSString *nick = [RSA encryptString:self.nick_name publicKey:PublicKey];
    NSString *avatarUrl = [RSA encryptString:self.photo_url publicKey:PublicKey];
    NSString *password = [RSA encryptString:[self.passwordTextField.text md5String] publicKey:PublicKey];
    NSString *repassword = [RSA encryptString:[self.confirmPasswordTextField.text md5String] publicKey:PublicKey];
    NSString *udid = [RSA encryptString:[DLayout identifier] publicKey:PublicKey];
    NSString *device = [RSA encryptString:[DLayout phoneVersion] publicKey:PublicKey];
    NSString *openID = [RSA encryptString:self.openID publicKey:PublicKey];
    
    NSString *par = [NSString stringWithFormat:@"{\"user_mobile\" : \"%@\", \"code\" : \"%@\", \"nick\" : \"%@\", \"avatarUrl\" : \"%@\", \"password\" : \"%@\", \"repassword\" : \"%@\", \"udid\" : \"%@\", \"device\" : \"%@\", \"openId\" : \"%@\"}", user_mobile, code, nick, avatarUrl, password, repassword, udid, device, openID];
    
    [PPNetworkHelper POST:@"user/login/empowerCreateuser" parameters:@{@"json" : par} success:^(id responseObject) {
        
        NSLog(@"绑定手机号%@", responseObject);
        
        if ([responseObject[@"code"] integerValue] == 1) {
            
            [CommonUserInfo sharedInstance].isLogin = YES;
            [CommonUserInfo sharedInstance].phone = [[NSString alloc] initWithFormat:@"%@", responseObject[@"data"][@"user_mobile"]];
            [CommonUserInfo sharedInstance].user_id = [[NSString alloc] initWithFormat:@"%@", responseObject[@"data"][@"user_id"]];
            
            [CommonUserInfo sharedInstance].nickName = [[NSString alloc] initWithFormat:@"%@", responseObject[@"data"][@"user_name"]];
            
            [[KYAlertView sharedInstance] showAlertViewWithMessage:responseObject[@"msg"]];
            
            [self dismissViewControllerAnimated:YES completion:nil];
            
            UIWindow *window = [UIApplication sharedApplication].keyWindow;
            window.rootViewController = [BaseTabbarViewController sharedMainTabBarVC];
            
        }else {
            
            [[KYAlertView sharedInstance] showAlertViewWithMessage:responseObject[@"msg"]];
            
        }
        
    } failure:^(NSError *error) {
        
        if (error) {
            
            [[KYAlertView sharedInstance] showAlertViewWithMessage:Tip];
        }
    }];
    
}

- (void)createView {
    
    [self.view addSubview:self.contentScrollView];
    
    [self.contentScrollView addSubview:self.titileIV];
    
    [self.contentScrollView addSubview:self.desL];
    [self.contentScrollView addSubview:self.leftIV];
    [self.contentScrollView addSubview:self.rightIV];
    
    [self.contentScrollView addSubview:self.phoneIV];
    [self.contentScrollView addSubview:self.phoneL];
    [self.contentScrollView addSubview:self.phoneZoneL];
    [self.contentScrollView addSubview:self.phoneTextField];
    [self.contentScrollView addSubview:self.shortLineIV];
    [self.contentScrollView addSubview:self.middleLineIV];
    
    [self.contentScrollView addSubview:self.codeIV];
    [self.contentScrollView addSubview:self.codeL];
    [self.contentScrollView addSubview:self.codeTextField];
    [self.contentScrollView addSubview:self.getCodeBtn];
    [self.contentScrollView addSubview:self.codeLineIV];
    
    [self.contentScrollView addSubview:self.passwordIV];
    [self.contentScrollView addSubview:self.passwordL];
    [self.contentScrollView addSubview:self.passwordTextField];
    [self.contentScrollView addSubview:self.passwordLineIV];
    
    [self.contentScrollView addSubview:self.confirmPasswordIV];
    [self.contentScrollView addSubview:self.confirmPasswordL];
    [self.contentScrollView addSubview:self.confirmPasswordTextField];
    [self.contentScrollView addSubview:self.confirmPasswordLineIV];
    
    [self.contentScrollView addSubview:self.registerProtocolL];
    [self.contentScrollView addSubview:self.protocolL];
    
    [self.view addSubview:self.registerBtn];
    [self.view addSubview:self.registerL];
    
    __weak typeof(self) weakSelf = self;
    
    [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left);
        make.right.mas_equalTo(weakSelf.view.mas_right);
        make.top.mas_equalTo(weakSelf.view.mas_top);
        make.bottom.mas_equalTo(weakSelf.view.mas_bottom);
        
    }];
    
    [self.titileIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.view.mas_centerX);
        
        //        if (Device_Is_iPhoneX) {
        //
        //            make.top.mas_equalTo(weakSelf.view.mas_top).with.offset(jisuan(240));
        //
        //        }else {
        
        //            make.top.mas_equalTo(weakSelf.view.mas_top).with.offset(jisuan(40));
        make.top.mas_equalTo(weakSelf.contentScrollView.mas_top).with.offset(jisuan(80));
        
        //        }
        
        
        make.width.mas_equalTo(jisuan(252));
        make.height.mas_equalTo(jisuan(80));
        
    }];
    
    [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(weakSelf.contentScrollView.top).with.offset(jisuan(284));
        make.centerX.mas_equalTo(weakSelf.view.mas_centerX);
        
    }];
    [self.leftIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.desL.mas_left).with.offset(-jisuan(28));
        make.centerY.mas_equalTo(weakSelf.desL.mas_centerY);
        make.width.mas_equalTo(jisuan(32));
        make.height.mas_equalTo(jisuan(4));
    }];
    
    [self.rightIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.desL.mas_right).with.offset(jisuan(28));
        make.centerY.mas_equalTo(weakSelf.desL.mas_centerY);
        make.width.mas_equalTo(jisuan(32));
        make.height.mas_equalTo(jisuan(4));
        
    }];
    
    [self.phoneIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.desL.mas_bottom).with.offset(jisuan(100));
        make.width.mas_equalTo(jisuan(30));
        make.height.mas_equalTo(jisuan(40));
        
    }];
    [self.phoneL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.phoneIV.mas_right).with.offset(Margin);
        make.centerY.mas_equalTo(weakSelf.phoneIV.mas_centerY);
        make.width.mas_equalTo(jisuan(56));
        make.height.mas_equalTo(jisuan(34));
    }];
    [self.phoneZoneL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.phoneL.mas_right).with.offset(jisuan(40));
        
        make.centerY.mas_equalTo(weakSelf.phoneIV.mas_centerY);
        make.width.mas_equalTo(jisuan(60));
        make.height.mas_equalTo(jisuan(40));
        
    }];
    [self.phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.phoneZoneL.mas_right).with.offset(Margin);
        
        make.centerY.mas_equalTo(weakSelf.phoneIV.mas_centerY);
        make.right.mas_equalTo(weakSelf.view.mas_right).with.offset(-jisuan(100));
        make.height.mas_equalTo(jisuan(34));
        
    }];
    [self.shortLineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.phoneIV.mas_bottom).with.offset(Margin);
        make.width.mas_equalTo(jisuan(104));
        make.height.mas_equalTo(jisuan(2));
    }];
    [self.middleLineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.shortLineIV.mas_right).with.offset(jisuan(38));
        make.top.mas_equalTo(weakSelf.phoneIV.mas_bottom).with.offset(Margin);
        make.width.mas_equalTo(jisuan(414));
        make.height.mas_equalTo(jisuan(2));
    }];
    
    [self.codeIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.shortLineIV.mas_bottom).with.offset(jisuan(58));
        make.width.mas_equalTo(jisuan(32));
        make.height.mas_equalTo(jisuan(40));
    }];
    
    [self.codeL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.codeIV.mas_right).with.offset(jisuan(18));
        make.centerY.mas_equalTo(weakSelf.codeIV.mas_centerY);
        make.width.mas_equalTo(jisuan(78));
        make.height.mas_equalTo(jisuan(34));
        
    }];
    
    [self.getCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.view.mas_right).with.offset(-jisuan(120));
        make.centerY.mas_equalTo(weakSelf.codeIV.mas_centerY);
        make.width.mas_equalTo(jisuan(130));
        make.height.mas_equalTo(jisuan(34));
    }];
    
    [self.codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.codeL.mas_right).with.offset(jisuan(40));
        make.centerY.mas_equalTo(weakSelf.codeIV.mas_centerY);
        make.right.mas_equalTo(weakSelf.getCodeBtn.mas_left).with.offset(-jisuan(38));
        make.height.mas_equalTo(jisuan(34));
    }];
    [self.codeLineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.codeIV.mas_bottom).with.offset(Margin);
        make.width.mas_equalTo(jisuan(374));
        make.height.mas_equalTo(jisuan(2));
    }];
    
    [self.passwordIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.codeLineIV.mas_bottom).with.offset(jisuan(58));
        make.width.mas_equalTo(jisuan(32));
        make.height.mas_equalTo(jisuan(40));
    }];
    
    [self.passwordL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.passwordIV.mas_right).with.offset(jisuan(18));
        make.centerY.mas_equalTo(weakSelf.passwordIV.mas_centerY);
        make.width.mas_equalTo(jisuan(56));
        make.height.mas_equalTo(jisuan(34));
        
    }];
    
    [self.passwordTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.passwordL.mas_right).with.offset(jisuan(64));
        make.centerY.mas_equalTo(weakSelf.passwordIV.mas_centerY);
        make.right.mas_equalTo(weakSelf.view.mas_right).with.offset(-jisuan(100));
        make.height.mas_equalTo(jisuan(34));
    }];
    
    [self.passwordLineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.passwordIV.mas_bottom).with.offset(Margin);
        make.width.mas_equalTo(jisuan(554));
        make.height.mas_equalTo(jisuan(2));
    }];
    
    [self.confirmPasswordIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.passwordLineIV.mas_bottom).with.offset(jisuan(58));
        make.width.mas_equalTo(jisuan(32));
        make.height.mas_equalTo(jisuan(40));
    }];
    
    [self.confirmPasswordL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.confirmPasswordIV.mas_right).with.offset(jisuan(18));
        make.centerY.mas_equalTo(weakSelf.confirmPasswordIV.mas_centerY);
        make.width.mas_equalTo(jisuan(100));
        make.height.mas_equalTo(jisuan(34));
        
    }];
    
    [self.confirmPasswordTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.confirmPasswordL.mas_right).with.offset(jisuan(16));
        make.centerY.mas_equalTo(weakSelf.confirmPasswordL.mas_centerY);
        make.right.mas_equalTo(weakSelf.view.mas_right).with.offset(-jisuan(100));
        make.height.mas_equalTo(jisuan(34));
    }];
    
    [self.confirmPasswordLineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.confirmPasswordIV.mas_bottom).with.offset(Margin);
        make.width.mas_equalTo(jisuan(554));
        make.height.mas_equalTo(jisuan(2));
    }];
    
    
    [self.registerProtocolL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.view.mas_left).with.offset(jisuan(100));
        make.top.mas_equalTo(weakSelf.confirmPasswordLineIV.mas_bottom).with.offset(jisuan(62));
        
        
    }];
    [self.protocolL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.registerProtocolL.mas_right);
        make.centerY.mas_equalTo(weakSelf.registerProtocolL.mas_centerY);
        
        
    }];
    
    [self.registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.view.mas_centerX);
        make.top.mas_equalTo(weakSelf.protocolL.mas_bottom).with.offset(jisuan(100));
        //        make.bottom.mas_equalTo(weakSelf.view.mas_bottom).with.offset(-jisuan(64));
        make.width.mas_equalTo(jisuan(410));
        make.height.mas_equalTo(jisuan(106));
    }];
    
    [self.registerL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(weakSelf.registerBtn.mas_centerY);
        make.centerX.mas_equalTo(weakSelf.registerBtn.mas_centerX);
        
    }];
    
    [self.view layoutIfNeeded];
    
    self.contentScrollView.contentSize = CGSizeMake(WIDTH, CGRectGetMaxY(self.registerBtn.frame) + jisuan(106) + jisuan(100));
    
}

#pragma mark -lazy
- (UIScrollView *)contentScrollView {
    
    if (!_contentScrollView) {
        
        _contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero];
        
        _contentScrollView.showsVerticalScrollIndicator = NO;
        _contentScrollView.showsHorizontalScrollIndicator = NO;
        
        if (@available(iOS 11.0, *)) {
            
            _contentScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
    }
    
    return _contentScrollView;
}

- (UIImageView *)titileIV {
    
    if (!_titileIV) {
        
        _titileIV = [[UIImageView alloc] init];
        _titileIV.image = [UIImage imageNamed:@"titleIvBG"];
        _titileIV.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    
    return _titileIV;
}

- (UIImageView *)leftIV {
    
    if (!_leftIV) {
        
        _leftIV = [[UIImageView alloc] init];
        _leftIV.image = [UIImage imageNamed:@"leftIVBG"];
        _leftIV.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    
    return _leftIV;
}

- (UIImageView *)rightIV {
    
    if (!_rightIV) {
        
        _rightIV = [[UIImageView alloc] init];
        _rightIV.image = [UIImage imageNamed:@"rightIVbg"];
        _rightIV.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    
    return _rightIV;
}

- (UILabel *)desL {
    
    if (!_desL) {
        
        _desL = [[UILabel alloc] init];
        _desL.text = @"一款让你爱上购物的APP";
        _desL.textColor = Color333333;
        _desL.font = [UIFont fontWithName:@":MFYueYuan_Noncommercial-Regular" size:jisuan(32)];
        
        _desL.textAlignment = NSTextAlignmentCenter;
    }
    
    return _desL;
}

- (UIImageView *)phoneIV {
    
    if (!_phoneIV) {
        
        _phoneIV = [[UIImageView alloc] init];
        _phoneIV.contentMode = UIViewContentModeScaleAspectFit;
        _phoneIV.image = [UIImage imageNamed:@"phoneBG"];
        
    }
    
    return _phoneIV;
}

- (UILabel *)phoneL {
    
    if (!_phoneL) {
        
        _phoneL = [[UILabel alloc] init];
        _phoneL.text = @"手机";
        _phoneL.textColor = Color333333;
        _phoneL.font = Font(24);
        _phoneL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _phoneL;
    
}
- (UILabel *)phoneZoneL {
    
    if (!_phoneZoneL) {
        
        _phoneZoneL = [[UILabel alloc] init];
        _phoneZoneL.text = @"+86";
        _phoneZoneL.textColor = Color333333;
        _phoneZoneL.font = Font(24);
        _phoneZoneL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _phoneZoneL;
    
}

- (UITextField *)phoneTextField {
    
    if (!_phoneTextField) {
        
        _phoneTextField = [[UITextField alloc] init];
        _phoneTextField.placeholder = @"请输入手机号";
        _phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        _phoneTextField.textColor = Color333333;
        _phoneTextField.font = Font(24);
        _phoneTextField.textAlignment = NSTextAlignmentLeft;
        
        _phoneTextField.clearButtonMode = UITextFieldViewModeAlways;
        
    }
    
    return _phoneTextField;
}

- (UIView *)shortLineIV {
    
    if (!_shortLineIV) {
        
        _shortLineIV = [[UIView alloc] init];
        _shortLineIV.backgroundColor = Colordddddd;
        
    }
    
    return _shortLineIV;
}

- (UIView *)middleLineIV {
    
    if (!_middleLineIV) {
        
        _middleLineIV = [[UIView alloc] init];
        _middleLineIV.backgroundColor = Colordddddd;
        
    }
    
    return _middleLineIV;
}

- (UIImageView *)codeIV {
    
    if (!_codeIV) {
        
        _codeIV = [[UIImageView alloc] init];
        _codeIV.contentMode = UIViewContentModeScaleAspectFit;
        _codeIV.image = [UIImage imageNamed:@"codeBG"];
    }
    
    return _codeIV;
}
- (UILabel *)codeL {
    
    if (!_codeL) {
        
        _codeL = [[UILabel alloc] init];
        _codeL.text = @"验证码";
        _codeL.textColor = Color333333;
        _codeL.font = Font(24);
        _codeL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _codeL;
}

- (UITextField *)codeTextField {
    
    if (!_codeTextField) {
        
        _codeTextField = [[UITextField alloc] init];
        _codeTextField.placeholder = @"请输入验证码";
        _codeTextField.keyboardType = UIKeyboardTypeNumberPad;
        _codeTextField.textAlignment = NSTextAlignmentLeft;
        _codeTextField.textColor = Color333333;
        _codeTextField.font = Font(24);
        
        //        UIImageView *imageV = [[UIImageView alloc] init];
        //
        //        self.imageV = imageV;
        //        imageV.frame = CGRectMake(0, 0, jisuan(29), jisuan(20));
        //        imageV.contentMode = UIViewContentModeScaleAspectFit;
        //        imageV.image = [UIImage imageNamed:@"codeErrorBG"];
        
        //        _codeTextField.rightView = imageV;
        _codeTextField.rightViewMode = UITextFieldViewModeAlways;
        
//        _codeTextField.delegate = self;
        
    }
    
    return _codeTextField;
}

- (UIButton *)getCodeBtn {
    
    if (!_getCodeBtn) {
        
        _getCodeBtn = [[UIButton alloc] init];
        [_getCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
        [_getCodeBtn setTitleColor:Color333333 forState:UIControlStateNormal];
        _getCodeBtn.titleLabel.font = Font(24);
        [_getCodeBtn addTarget:self action:@selector(getCodeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _getCodeBtn;
}

- (UIView *)codeLineIV {
    
    if (!_codeLineIV) {
        
        _codeLineIV = [[UIView alloc] init];
        _codeLineIV.backgroundColor = Colordddddd;
        
    }
    
    return _codeLineIV;
}

- (UIImageView *)passwordIV {
    
    if (!_passwordIV) {
        
        _passwordIV = [[UIImageView alloc] init];
        _passwordIV.contentMode = UIViewContentModeScaleAspectFit;
        _passwordIV.image = [UIImage imageNamed:@"passwordBG"];
    }
    
    return _passwordIV;
}

- (UILabel *)passwordL {
    
    if (!_passwordL) {
        
        _passwordL = [[UILabel alloc] init];
        _passwordL.text = @"密码";
        _passwordL.textColor = Color333333;
        _passwordL.font = Font(24);
        _passwordL.textAlignment = NSTextAlignmentLeft;
    }
    
    return _passwordL;
    
}

- (UITextField *)passwordTextField {
    
    if (!_passwordTextField) {
        
        _passwordTextField = [[UITextField alloc] init];
        _passwordTextField.placeholder = @"请输入密码";
        _passwordTextField.keyboardType = UIKeyboardTypeDefault;
        _passwordTextField.textAlignment = NSTextAlignmentLeft;
        _passwordTextField.secureTextEntry = YES;
        _passwordTextField.textColor = Color333333;
        _passwordTextField.font = Font(24);
        _passwordTextField.clearButtonMode = UITextFieldViewModeAlways;
    }
    
    return _passwordTextField;
}

- (UIView *)passwordLineIV {
    
    if (!_passwordLineIV) {
        
        _passwordLineIV = [[UIView alloc] init];
        _passwordLineIV.backgroundColor = Colordddddd;
        
    }
    
    return _passwordLineIV;
}


- (UIImageView *)confirmPasswordIV {
    
    if (!_confirmPasswordIV) {
        
        _confirmPasswordIV = [[UIImageView alloc] init];
        _confirmPasswordIV.contentMode = UIViewContentModeScaleAspectFit;
        _confirmPasswordIV.image = [UIImage imageNamed:@"passwordBG"];
    }
    
    return _confirmPasswordIV;
    
}

- (UILabel *)confirmPasswordL {
    
    if (!_confirmPasswordL) {
        
        _confirmPasswordL = [[UILabel alloc] init];
        _confirmPasswordL.text = @"确认密码";
        _confirmPasswordL.textColor = Color333333;
        _confirmPasswordL.font = Font(24);
        _confirmPasswordL.textAlignment = NSTextAlignmentLeft;
        
    }
    
    return _confirmPasswordL;
}

- (UITextField *)confirmPasswordTextField {
    
    if (!_confirmPasswordTextField) {
        
        _confirmPasswordTextField = [[UITextField alloc] init];
        _confirmPasswordTextField.placeholder = @"再次确认密码";
        _confirmPasswordTextField.keyboardType = UIKeyboardTypeDefault;
        _confirmPasswordTextField.textAlignment = NSTextAlignmentLeft;
        _confirmPasswordTextField.textColor = Color333333;
        _confirmPasswordTextField.font = Font(24);
        _confirmPasswordTextField.secureTextEntry = YES;
        _confirmPasswordTextField.clearButtonMode = UITextFieldViewModeAlways;
        
    }
    
    return _confirmPasswordTextField;
}

- (UIView *)confirmPasswordLineIV {
    
    if (!_confirmPasswordLineIV) {
        
        _confirmPasswordLineIV = [[UIView alloc] init];
        _confirmPasswordLineIV.backgroundColor = Colordddddd;
        
    }
    
    return _confirmPasswordLineIV;
}

- (UILabel *)registerProtocolL {
    
    if (!_registerProtocolL) {
        
        _registerProtocolL = [[UILabel alloc] init];
        _registerProtocolL.text = @"注册即视为同意";
        _registerProtocolL.textColor = Color333333;
        _registerProtocolL.font = Font(20);
        _registerProtocolL.textAlignment = NSTextAlignmentLeft;
        
    }
    
    return _registerProtocolL;
}

- (UILabel *)protocolL {
    
    if (!_protocolL) {
        
        _protocolL = [[UILabel alloc] init];
        _protocolL.textAlignment = NSTextAlignmentLeft;
        _protocolL.text = @"《爱淘帮会员-用户协议》";
        _protocolL.textColor = Color1f89ff;
        _protocolL.font = Font(20);
        
        _protocolL.userInteractionEnabled = YES;
        UITapGestureRecognizer *protocolGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(protocolClick:)];
        [_protocolL addGestureRecognizer:protocolGesture];
    }
    
    return _protocolL;
}

- (UIButton *)registerBtn {
    
    if (!_registerBtn) {
        
        _registerBtn = [[UIButton alloc] init];
        [_registerBtn setImage:[UIImage imageNamed:@"cmmonBtnBG"] forState:UIControlStateNormal];
        [_registerBtn setImage:[UIImage imageNamed:@"cmmonBtnBG"] forState:UIControlStateHighlighted];
        
        [_registerBtn addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    return _registerBtn;
}
- (UILabel *)registerL {
    
    if (!_registerL) {
        
        _registerL = [[UILabel alloc] init];
        _registerL.textAlignment = NSTextAlignmentCenter;
        _registerL.text = @"绑定";
        _registerL.textColor = WhiteColor;
        _registerL.font = Font(30);
        
        _registerL.userInteractionEnabled = YES;
        UITapGestureRecognizer *registerLGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(registerLClick:)];
        [_registerL addGestureRecognizer:registerLGesture];
    }
    
    return _registerL;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
